<?php

class user extends model {
	
	private $_Username;
	private $_Password;
	private $_Name;
	private $_Surname;
	
	public function __construct($arrInitialValues = null){
		$this->setTable('users');
		$this->setColumnId('user_id');
		parent::__construct($arrInitialValues);
		$this->_setDefaultValues($arrInitialValues);
	}
	
	private function _setDefaultValues($arrInitialValues){
		if (isset($arrInitialValues['username']) && !empty($arrInitialValues['username']))
			$this->setUsername($arrInitialValues['username']);
		else 
			$this->setUsername('');
			
		if (isset($arrInitialValues['password']) && !empty($arrInitialValues['password']))
			$this->setPassword($arrInitialValues['password']);
		else 
			$this->setPassword('');
			
		if (isset($arrInitialValues['name']) && !empty($arrInitialValues['name']))
			$this->setName($arrInitialValues['name']);
		else 
			$this->setName('');
			
		if (isset($arrInitialValues['surname']) && !empty($arrInitialValues['surname']))
			$this->setSurname($arrInitialValues['surname']);
		else 
			$this->setSurname('');
	}
	
	/**
	 * @return the $_Username
	 */
	public function getUsername() {
		return $this->_Username;
	}

	/**
	 * @return the $_Password
	 */
	public function getPassword() {
		return $this->_Password;
	}

	/**
	 * @return the $_Name
	 */
	public function getName() {
		return $this->_Name;
	}

	/**
	 * @return the $_Surname
	 */
	public function getSurname() {
		return $this->_Surname;
	}

	/**
	 * @param field_type $_Username
	 */
	public function setUsername($_Username) {
		$this->_Username = $_Username;
	}

	/**
	 * @param field_type $_Password
	 */
	public function setPassword($_Password) {
		$this->_Password = $_Password;
	}

	/**
	 * @param field_type $_Name
	 */
	public function setName($_Name) {
		$this->_Name = $_Name;
	}

	/**
	 * @param field_type $_Surname
	 */
	public function setSurname($_Surname) {
		$this->_Surname = $_Surname;
	}
	
	public function getWholeName(){
		return $this->getName() . ' ' . $this->getSurname();
	}
	
	public function getUser(){
		$query = '
			SELECT *
			FROM users
			WHERE user_id = ' . $this->getId();
		
		$dbHelper = new DBHelper($query);
		return $dbHelper->getResult();
	}

}

?>